package com.swt.controller;

import com.swt.common.vo.ResponseVo;
import com.swt.domain.Admin;
import com.swt.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

/**
 * @Description
 * @Author swt
 * @Date 2022/5/18
 */
@RestController
@RequestMapping("/login")
public class LoginController {

    @Autowired
    private AdminService adminService;

    @PostMapping
    public ResponseVo login(@RequestBody Admin admin){

        return adminService.login(admin)? ResponseVo.SUCCESS("123456") : ResponseVo.FAIL("用户名密码错误");
    }


    @GetMapping("/info")
    public ResponseVo loginInfo(HttpServletRequest request){
        System.out.println(request);
        HashMap<String,String> map = new HashMap<>();
        map.put("name","admin");
        map.put("photographPath","http://rb7dliol1.bkt.clouddn.com/201512720292758506.gif");
        return ResponseVo.SUCCESS(map);
    }

}
